{extend name="../../base/view/layout" /}
{block name="my_body"}
<div class="widgetbox box-inverse">
    <div class="widgetcontent wc1">

        <form id="form1" class="stdform" >
            <div class="tabbable">
                <ul class="nav nav-tabs buttons-icons">
                    <li class="active"><a data-toggle="tab" href="#shop_info"><?php echo $_page_title;?></a></li>
                </ul>
                <div class="tab-content">
                    <div id="shop_info" class="tab-pane active">

            <div class="par control-group">
                <label class="control-label" for="parent_id">上级权限</label>
                <span class="field">
                            <select name="parent_id" class="uniformselect" id="parent_id">
                            	<option value="0">顶级权限</option>
                                <?php foreach($data as $v):?>
                                <option value="<?php echo $v['id'];?>"><?php echo str_repeat('-',$v['level']),$v['pri_name'];?></option>
                                <?php endforeach;?>
                            </select>
                            </span>
            </div>
            <div class="par control-group">
                <label class="control-label" for="pri_name">权限名称</label>
                <div class="controls"><input type="text" name="pri_name" id="pri_name" class="input-xlarge" /></div>
            </div>
            <div class="par control-group">
                <label class="control-label" for="module_name">模块名称</label>
                <div class="controls"><input type="text" name="module_name" id="module_name" class="input-xlarge" /></div>
            </div>
            <div class="par control-group">
                <label class="control-label" for="controller_name">控制器名称</label>
                <div class="controls"><input type="text" name="controller_name" id="controller_name" class="input-xlarge" /></div>
            </div>
            <div class="par control-group">
                <label class="control-label" for="action_name">方法名称</label>
                <div class="controls"><input type="text" name="action_name" id="action_name" class="input-xlarge" /></div>
            </div>
            <div class="par control-group">
                <label class="control-label" for="ico">图标</label>
                <div class="controls"><input type="text" name="ico" id="ico" class="input-xlarge" /></div>
            </div>
            <div class="par control-group">
                <label class="control-label" for="sort_num">排序</label>
                <div class="controls"><input type="text" name="sort_num" id="sort_num" class="input-xlarge" value="100" /></div>
            </div>
                    </div>
                </div>
            </div>


            <p class="stdformbutton">
                <a class="btn btn-primary">提交</a>
            </p>
        </form>
    </div><!--widgetcontent-->
</div><!--widget-->
{/block}

{block name="my_js"}
<script>
    var url = "<?php echo url('add');?>";
    var jumpUrl = "<?php echo url('lst');?>";
    jQuery('.stdformbutton .btn').click(function(){
    var formData = jQuery("#form1").serialize();//序列化表格内容为字符串
            jQuery.ajax({
                type: 'POST',
                url: url,
                data: formData ,
                dataType: 'JSON',
                success: function(res){
                    if(res.code == 0)
                    {
                        window.location.href=jumpUrl;
                    }
                    else
                    {
                        var html = '<div class="widgetbox box-danger"><h4 class="widgettitle">错误提示 <a class="close">×</a> <a class="minimize">–</a></h4><div class="widgetcontent">'+res.msg+'</div></div>';
                        var h = jQuery(html);
                        jQuery(".widgetcontent").prepend(h);
                        window.setTimeout(function(){
                            h.remove();
                        },1000);
                    }
                }
            })
        }
    );
</script>
{/block}